// Replication commands for: 
// ``International Institutions and Civil War Prevention''
// Johannes Karreth and Jaroslav Tir
// Journal of Politics 75 (1): 96-109.
// Last updated: January 27, 2012
// Corresponding: johannes.karreth@colorado.edu
// Data and replication command stored at:
// http://dvn.iq.harvard.edu/dvn/dv/jkarreth

// Setup

clear all
use "igo.cw.replication.dta"

// Analyses in the article

//// Table 1

////// Model 1
logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log if year<2001, vce(cluster ccode) nolog difficult technique (bfgs) 

////// Model 2
logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d if year<2001, vce(cluster ccode) nolog difficult technique (bfgs) 

////// Model 3
heckprob escalation_d hsigo msigo lsigo polity polity_sq gdppc_log if year<2001, select(conflict_d = hsigo msigo lsigo polity polity_sq gdppc_log population_log ethfrac mountains_log oilexp_d muslim_pct confpast10_d) vce(cluster ccode) nolog difficult technique(bfgs)

////// Model 4
heckprob escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d if year<2001, select(conflict_d = hsigo msigo lsigo polity polity_sq gdppc_log population_log ethfrac mountains_log oilexp_d muslim_pct confpast10_d) vce(cluster ccode) nolog difficult technique(bfgs)

//// Table 2

////// Model 5: Mediation & Intervention
logit escalation_d hsigo  polity_sq  mountains_log exclpop_log settlepast10_d interv_sum mediat_sum if year<2001 & id_regancw==1, vce(cluster ccode) nolog difficult technique (bfgs) 

////// Model 6: IV
ivprobit escalation_d (hsigo = noconfyrs_log polity gdppc_log trade_log) polity_sq population_log mountains_log exclpop_log settlepast10_d if year<2001, nolog mle cluster(ccode)

////// Model 7: Cost-Benefit HSIGOs
logit escalation_d hsigo_cb msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d if year<2001, vce(cluster ccode) nolog difficult technique (bfgs)

////// Model 8: Settlement model
logit confend_d hsigo polity polity_sq gdppc_log population_log mountains_log exclpop_log settlepast10_d, vce(cluster ccode) nolog

// Online appendix

//// Table A4: Controlling for temporal and spatial trends
logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d year americas_d asia_d europe_d mideast_d if year<2001, vce(cluster ccode) nolog difficult technique (bfgs)

//// Table A5: Controlling for rebel financing: natural resources
logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d  gemstone_d hydrocarb_d if year<2001, vce(cluster ccode) nolog difficult technique (bfgs) 

logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d gemhydroc_d hsigoXgemhydroc if year<2001, vce(cluster ccode) nolog difficult technique (bfgs)

// Predicted probabilities and graphs produced using R

// Syria simulation mentioned in the article

use "igo.cw.replication.dta"

logit escalation_d hsigo msigo lsigo polity polity_sq gdppc_log population_log  mountains_log exclpop_log settlepast10_d if year<2001, vce(cluster ccode) nolog difficult technique (bfgs) 

clear
set obs 1
gen hsigo = 11
gen msigo = 6
gen lsigo = 24
gen polity = -7
gen polity_sq = 49
gen gdppc_log = 8.536996
gen population_log = 9.663007
gen mountains_log = 1.856298
gen exclpop_log = 4.4543471
gen settlepast10_d = 0
gen ccode = 652
gen year = .

predict PrEscalation
predict XBeta, xb
predict seXB, stdp
gen Lindex=XBeta-invnorm(0.95)*seXB
gen Uindex=XBeta+invnorm(0.95)*seXB
gen L_prob=exp(Lindex) / (1+exp(Lindex))
gen U_prob=exp(Uindex) / (1+exp(Uindex))

list L_prob PrEscalation U_prob